package com.example.wechattest.myAdapter;

import android.content.Context;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.Lifecycle;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import com.example.wechattest.ConnectFragment;
import com.example.wechattest.FindFragment;
import com.example.wechattest.wechatFragment;

public class MyAdapter extends FragmentStateAdapter {

    private Context context;
    private int num;

    public MyAdapter(@NonNull FragmentManager fragmentManager, @NonNull Lifecycle lifecycle, Context context, int num) {
        super(fragmentManager, lifecycle);
        this.context = context;
        this.num = num;
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        switch (position){
            case 0:
                return new wechatFragment(context);
            case 1:
                return new ConnectFragment();
            case 2:
                return new FindFragment();
        }
        return null;
    }

    @Override
    public int getItemCount() {
        return num;
    }
}
